{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-01T10:29:59.213482Z",
     "start_time": "2025-09-01T10:29:59.207238Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "from sklearn.metrics import confusion_matrix\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt"
   ],
   "outputs": [],
   "execution_count": 17
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T10:29:59.219240Z",
     "start_time": "2025-09-01T10:29:59.215004Z"
    }
   },
   "cell_type": "code",
   "source": [
    "plt.rcParams['font.sans-serif']=['KaiTi']#设置中文字体\n",
    "plt.rcParams['axes.unicode_minus']=False#解决负号显示的问题"
   ],
   "id": "36d314a1de9e0998",
   "outputs": [],
   "execution_count": 18
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T10:29:59.225264Z",
     "start_time": "2025-09-01T10:29:59.220368Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#定义类别标签\n",
    "labels=[\"猫\",\"狗\"]\n",
    "#定义数据（预测值和真实值）\n",
    "y_true= [\"猫\", \"猫\", \"猫\", \"猫\", \"猫\", \"猫\", \"狗\", \"狗\", \"狗\", \"狗\"]\n",
    "y_pred= [\"猫\", \"猫\", \"狗\", \"猫\", \"猫\", \"猫\", \"猫\", \"猫\", \"狗\", \"狗\"] "
   ],
   "id": "674768e19cf4bb3",
   "outputs": [],
   "execution_count": 19
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T10:29:59.232335Z",
     "start_time": "2025-09-01T10:29:59.226859Z"
    }
   },
   "cell_type": "code",
   "source": [
    "#得到混淆矩阵\n",
    "matrix = confusion_matrix(y_true, y_pred,labels=labels)\n",
    "print(pd.DataFrame(matrix,columns=labels,index=labels))"
   ],
   "id": "6407dd40fa73017a",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "   猫  狗\n",
      "猫  5  1\n",
      "狗  2  2\n"
     ]
    }
   ],
   "execution_count": 20
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T10:29:59.478510Z",
     "start_time": "2025-09-01T10:29:59.232335Z"
    }
   },
   "cell_type": "code",
   "source": "sns.heatmap(matrix,annot=True,fmt='d',cmap=\"Greens\",xticklabels=labels,yticklabels=labels)",
   "id": "341f5459651c3da7",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "<Figure size 640x480 with 2 Axes>"
      ],
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgAAAAGgCAYAAADcjN+JAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/TGe4hAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAnUklEQVR4nO3de3RU9b338c/MJBOCkRgTothw85YsLgk8EFGkEsD0FCgQD6LFp7VlISZW4mNJ8TQIgiaKiTdElqfBqgcVWrn5FFqirZwq+hRWQAgcsJiLF0AwBCaAExNGkjx/nJ1pcxLCDE7YIb/3i7X/2Nv9u8xaZu3vfL+/3x5HU1NTkwAAgFGcdk8AAABceAQAAAAYiAAAAAADEQAAAGAgAgAAAAxEAAAAgIEIAAAAMBABAAAABiIAAADAQAQAAAAYiAAAAACb5efnKzEx0X+kp6efs01ZWZmmTp2q1NRUFRQUKNg3+xMAAABgs71792r58uXavn27tm/frrfeeqvd+30+n7KysjRw4ECtW7dOlZWVWr9+fVBjEgAAAGCjM2fOqLy8XMOHD1ePHj3Uo0cPRUVFtdtmy5Yt8nq9ys3NVZ8+fTRnzhytXbs2qHEJAAAA6AA+n09er7fF4fP5Wt1XVlamxsZGZWRkKDk5WTNnztThw4fb7Xv//v1KSUlRZGSkJCkxMVGVlZVBzS8sqLs7gCM9we4pAJ1O3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ePH9dXX32loqIixcXFadWqVbrssst0xx136NixY+rZs6fd0wUumMjISDU1Nem5555TRkaGvv76az300EM6ceKEKioq/CWBxsbGoH50BeiMCAAMtHLlSo0dO1aJiYk6c+aMkpOT5fP59NRTT+mzzz7Tc889py+++EKXXXaZevToYfd0gQuqqKhI99xzj+Lj4+VwODRw4EDV1dXp2LFj+slPfiJJqqurU1gYFVRc3AgADOP1ejV69GiNGjVKHo9HERER6t69uyIjIzV37lwNGTJE+fn5amxsVHx8vN3TBS6okpISjRkzRkOGDFFNTY0iIyOVlpam2NhYPfnkk4qLi5MkVVVVBf3aVaCzIYQ1TFRUlKKiorRp0yZt2LBB//Iv/yJJ+vbbb7VkyRLt27dPd9xxh3w+n6655hqbZwtcWDfccIPq6+u1Y8cO7dy5U/fff79SUlL8/72qqkqRkZGqqalRVFSUjTMFvjsyAIa68cYbVV1drfT0dEnS6NGjddttt2nDhg1atWqVkpOTlZaWZu8kARt069ZN5eXlCgsLa5UF83g8GjlyJH8b6BL4MSC06fDhw7riiiuC+m1poCuprq5ucxFsUVGR7rrrLl166aU2zAoIHQIAAAAMRAkAAAADEQAAAGAgAgAAAAxEAAAAgIEIAAAAMBABAAAABiIAAADAQAQAAAAYiAAAAAADEQAAAGCg/w88VkBisRZFjwAAAABJRU5ErkJggg=="
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "execution_count": 21
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T10:29:59.483374Z",
     "start_time": "2025-09-01T10:29:59.479018Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import accuracy_score\n",
    "accuracy = accuracy_score(y_true, y_pred)#准确率\n",
    "print(accuracy)"
   ],
   "id": "572dc4d1ec31dba1",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7\n"
     ]
    }
   ],
   "execution_count": 22
  },
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "",
   "id": "7f332fe91df09fae"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T10:30:41.225926Z",
     "start_time": "2025-09-01T10:30:41.217267Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import precision_score\n",
    "precision = precision_score(y_true, y_pred,pos_label=\"猫\")#精确率\n",
    "print(precision)"
   ],
   "id": "c52525025f7aa152",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7142857142857143\n"
     ]
    }
   ],
   "execution_count": 25
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T10:33:34.835816Z",
     "start_time": "2025-09-01T10:33:34.825632Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import recall_score#召回率\n",
    "recall = recall_score(y_true,y_pred,pos_label=\"猫\")\n",
    "print(recall)"
   ],
   "id": "1bb697c1beb5d8f",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.8333333333333334\n"
     ]
    }
   ],
   "execution_count": 26
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "from sklearn.metrics import f1_score\n",
    "F1 = f1_score(y_true,y_pred,pos_label=\"猫\")#f1分数\n",
    "print(F1)"
   ],
   "id": "262df9a860b35662"
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-01T10:37:48.528803Z",
     "start_time": "2025-09-01T10:37:48.517191Z"
    }
   },
   "cell_type": "code",
   "source": [
    "from sklearn.metrics import classification_report\n",
    "report = classification_report(y_true, y_pred,labels=labels,target_names=None)\n",
    "print(report)"
   ],
   "id": "721e18eaef8b77ff",
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "           猫       0.71      0.83      0.77         6\n",
      "           狗       0.67      0.50      0.57         4\n",
      "\n",
      "    accuracy                           0.70        10\n",
      "   macro avg       0.69      0.67      0.67        10\n",
      "weighted avg       0.70      0.70      0.69        10\n",
      "\n"
     ]
    }
   ],
   "execution_count": 27
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "5f67fd0ccbd1cb8b"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
